﻿// See https://aka.ms/new-console-template for more information
public abstract class  Shape
{
     public abstract bool isLegal();
     public abstract double calArea();
}

class Rectangle : Shape
{
    double length
    {
        get { return length; }
        set { length = value; }
    }
    double height
    {
        get { return height; }
        set { height = value; }
    }
   
     public override bool isLegal()
    {
        if(length <=0||height <= 0)
        {
            Console.WriteLine("输入错误");
            return false;
        }
        return true;
    }
    public override double calArea()
    {
        
        return length * height;
    }
}

class Square : Rectangle
{
    double length
    {
        get { return length; }
        set { length = value; }
    }

        public override bool isLegal()
    {
        if (length <= 0)
        {
            Console.WriteLine("输入错误");
            return false;
        }
        return true ;
    }
          public override double calArea()
    {
        return length * length;
    }
    }

class Triangle : Shape
{
    double a
    {
        get { return a; }
        set { a = value; }
    }
    double b
    {
        get { return b; }
        set { b = value; }
    }
    double c
    {
        get { return c; }
        set { c = value; }
    }

    public override bool isLegal()
    {
        return (a + b > c && a + c > b && b + c > a) ;
    }

    public override double calArea()
    {
        double p = (a+b + c)/2;
        return p*(p-a)*(p-b)*(p-c);
    }
}

